/**
   
   Huffman.h
   =========
   
   Huffman code header
   
**/

#ifndef HUFFMAN_H
#define HUFFMAN_H


/**

   Includes
   --------

   bitfield.h  : struct bitfield needed

**/


#include <bitfield.h>


/**

   Structure: huff_node
   --------------------

   Huffman tree node

**/


struct huff_node
{
  unsigned char c;
  float freq;
  struct huff_node* left;
  struct huff_node* right;
};


/**

   Structure: huff_tree
   --------------------

   Huffman tree. Members are:
   - root  : Tree root
   - len   : Len of alphabet to en/de-code
   - code  : Hash table for ease of encoding

**/


struct huff_tree
{
  struct huff_node* root;
  uint16_t len;
  struct bitfield* code;
};



/**

   Prototypes
   ----------
**/

struct huff_tree* huff_create(void);
struct bitfield* huff_encode(char* str,struct huff_tree* tree);
int huff_delete(struct huff_tree* tree);

#endif
